package cn.lxh.ymcc.web.controller;


import cn.lxh.ymcc.result.JSONResult;
import cn.lxh.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;

    @GetMapping("/imageCode/{imageCodeKey}")
    /**
     * 接收请求路径中占位符sendSmsCode
     */
    public JSONResult imageCode(@PathVariable("imageCodeKey")  String key){

            String base64Str = verifyCodeService.imageCode(key);
            return JSONResult.success(base64Str);
    }
    /**
     * 接收请求路径中占位符sendSmsCode
     */
    @GetMapping("/sendSmsCode/{mobile}")
    public JSONResult sendSmsCode(@PathVariable("mobile")  String mobile){

       verifyCodeService.sendSmsCode(mobile);
        return JSONResult.success();
    }
}
